#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
const int maxn = 100;
int graph[maxn][maxn];
int book[maxn][maxn];

/**
 * 初始化棋盘
 */
void init() {
    graph[0][0] = 0;
    for (int i = 0; i < maxn; i++)
        for (int j = 0; j < maxn; j++) {
            if (i == 0 && j == 0)continue;
            graph[i][j] = 99999;
        }
}

/**
 * 方向数组
 */
int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1};

/**
 * 二维数组的基于BFS的遍历
 */
void bfs() {
    queue<pair<int, int>> Q;
    Q.push(make_pair(0, 0));
    book[0][0] = true;

    while (Q.size()) {
        int hx = Q.front().first;
        int hy = Q.front().second;
        int hz = graph[hx][hy];
        Q.pop();
        for (int i = 0; i < 8; i++) {
            int nx = hx + dx[i];
            int ny = hy + dy[i];
            if (nx < 0 || nx >= maxn || ny < 0 || ny >= maxn || book[nx][ny])continue;
            Q.push(make_pair(nx, ny));
            book[nx][ny] = 1;
            graph[nx][ny] = hz + 1;
        }
    }


}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    init();
    bfs();
    //for (int x, y; cin >> x >> y; cout << graph[x][y] << endl);
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            cout<<graph[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}